using System;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
using System.Configuration;

namespace Akabana.Amf.Messaging.Gateway.Configuration
{
	sealed class XmlConfigurator : IConfigurationSectionHandler
	{
		public object Create(object parent, object configContext, XmlNode section)
		{
            object settings = null;
            if (section == null)
                return settings;

            var xmlSerializer = new XmlSerializer(typeof(MessagingGatewaySettings));
            var reader = new XmlNodeReader(section);
            try
            {
                settings = xmlSerializer.Deserialize(reader);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                xmlSerializer = null;
            }
            return settings;
        
        }
	}
}
